<?php

namespace app\model;

use app\BaseModel;
use think\model\relation\BelongsTo;
use app\model\not_del\UserModel as NotDelUserModel;
use app\model\not_del\RatingScaleModel as NotDelRatingScaleModel;

/**
 * 心理咨询-消息内容
 */
class ConsultOnlineMessageModel extends BaseModel
{
    protected $name = 'consult_online_message';


    /**
     * 关联用户表
     * @return BelongsTo
     */
    public function user(): BelongsTo
    {
        return $this->belongsTo(NotDelUserModel::class,'uid')->bind([
            'user_name' => 'name',
            'user_avatar' => 'avatar'
        ]);
    }

    /**
     * 关联量表
     * @return BelongsTo
     */
    public function RatingScale(): BelongsTo
    {
        return $this->belongsTo(NotDelRatingScaleModel::class,'rating_scale_id')->bind([
            'rating_scale_name' => 'name',
            'rating_scale_cover' => 'cover'
        ]);
    }

    public function ConsultOnlineResult(): BelongsTo
    {
        return $this->belongsTo('ConsultOnlineResultModel','result_id')->bind([
            'is_follow'
        ]);
    }

    /**
     * 咨询记录
     * @return BelongsTo
     */
    public function ConsultOnline(): BelongsTo
    {
        return $this->belongsTo(ConsultOnlineModel::class,'online_id')->bind([
            'consult_id',
            'online_uid' => 'uid',
        ]);
    }
}